﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Collections;

namespace PatientInformationExtract.MainInterface.Models
{
    public class PatientListTreeItemCollection : ObservableCollection<ICheckableItem>
    {
        private PatientListTreeItem _owner;

        public PatientListTreeItemCollection(PatientListTreeItem owner)
            : base()
        {
            this._owner = owner;
        }

        public void Add(PatientListTreeItem patientListTreeItem)
        {
            base.Items.Add(patientListTreeItem);
            patientListTreeItem.Parent = this._owner;
        }

        public void Insert(int index, PatientListTreeItem patientListTreeItem)
        {
            base.Items.Insert(index, patientListTreeItem);
            patientListTreeItem.Parent = this._owner;
        }

        public bool Remove(PatientListTreeItem patientListTreeItem)
        {
            if (base.Items.Contains(patientListTreeItem))
            {
                base.Items.Remove(patientListTreeItem);
                patientListTreeItem.Parent = null;
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
